<template>
  <el-dialog :visible.sync="value" :before-close="cancel">
    <template slot="title">
      {{title}}
    </template>
    <el-form :model="form" :rules="auditRule" ref="auditForm" :label-width="formLabelWidth">


      <div style="padding: 10px 10px 10px 180px;">您确定要{{keywords}}此条策略吗？</div>
      <!-- <el-form-item label="备注" prop="comment">
        <el-col :span="16">
          <el-input type="textarea" v-model="form.comment" auto-complete="off"
          ></el-input>
        </el-col>
      </el-form-item> -->
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" @click="doSave({action: 'saveForm', form: 'auditForm'})">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>

  import {form} from '@/build'
  import {updateRiskStrategyStatusApi,deleteRiskStrategyStatusApi} from '@/services/api/strategy';

  export default {
    name: "strategy-status-dialog",
    props: ['value', 'id', 'status' , "rowData"],
    mixins: [form],
    data() {
      return {
        formLabelWidth: '180px',
        keywords: '',
        form: {
          id: this.id,
          status:this.status
        },
        auditRule: {
          comment: [
            {required: true, message: '备注不能为空', trigger: 'blur'},
          ],
        }
      }
    },

    computed: {
      title() {
        switch (this.status) {
          case 1:
            this.keywords = '启用';
            return '启用提现风控策略';
          case 0:
            this.keywords = '停用';
            return '停用提现风控策略';
          case 2:
            this.keywords = '删除';
            return '删除提现风控策略';
        }
      }
    },
    mounted() {
      let API = this.status === 2 ? deleteRiskStrategyStatusApi : updateRiskStrategyStatusApi
      this.bindSave(API, 'saveForm', 'form', {
        afterSuccess: () => {
          this.cancel()
          this.$parent.getAll()
        }
      });
    },
    methods: {
      cancel() {
        this.$emit('input', false);
      },
    },

  }
</script>

<style lang="scss" scoped>

</style>
